package server.proxy;

import java.io.IOException;


import files.handlers.FileHandler;
/**
 * This class perform all startup tasks for the server
 * 
 * @author Maxim
 *
 */
public class ServerStarterTask {
	
	public ServerStarterTask(String myAddress) throws IOException{
		
		createPasswordHTMLForm(myAddress);
		createPasswordErrorHTMLForm(myAddress);
		
		
	}
	
	
	private void createPasswordHTMLForm(String myAddress) throws IOException{
		
		String tNewForm = "<html><body><h3> In order to use this proxy server supply username and password <h3/><form action= http://" +myAddress;
		tNewForm+= " method=\"POST\">Username: <input type=\"text\" name=\"username\" /> <br/>password: <input type=\"password\" name=\"password\" /><p><input type=\"submit\" value= \"Connect\" /></p></form></body></html>";
		FileHandler.writeToFile(Config.PASSWORD_REQUEST_HTML_FILE_NAME, tNewForm, false);
		
	}
	
	
	private void createPasswordErrorHTMLForm(String myAddress) throws IOException{
		
		String tNewForm = "<html><body><h3> Your password or username is wrong, please try again <h3/><form action= http://" +myAddress;
		tNewForm+= " method=\"POST\">Username: <input type=\"text\" name=\"username\" /> <br/>password: <input type=\"password\" name=\"password\" /><p><input type=\"submit\" value= \"Connect\" /></p></form></body></html>";
		FileHandler.writeToFile(Config.INCORRECT_RASSWORD_HTML_FILE_NAME, tNewForm, false);
		
	}
	
	

	
	
	

}
